#include <iostream>
#include <string>
using namespace std;
class APA{
	public:
		virtual void print() = 0;
};

class APA1:public APA{
		string name;
	public:
		APA1(const string& nm):name(nm){}
		virtual void print(){
			cout << "APA1:" << name << endl;
		}
};

class APA2:public APA{
		string name;
	public:
		APA2(const string& nm):name(nm){}
		virtual void print(){
			cout << "APA2:" << name << endl;
		}
};


class APB{
	public:
		virtual void print() = 0;
};

class APB1:public APB{
		string name;
	public:
		APB1(const string& nm):name(nm){}
		virtual void print(){
			cout << "APB1:" << name << endl;
		}
};

class APB2:public APB{
		string name;
	public:
		APB2(const string& nm):name(nm){}
		virtual void print(){
			cout << "APB2:" << name << endl;
		}
};

class AF{
	public:
		virtual APA* createAPA(int) = 0;
		virtual APB* createAPB(int) = 0;
};

class CAF1:public AF{
	public:
		virtual APA* createAPA(int);
		virtual APB* createAPB(int);
};


APA* CAF1::createAPA(int type){
	if(type == 1)
		return new APA1("APA1Name");
	else
		return new APA2("APA2Name");
}

APB* CAF1::createAPB(int type){
	if(type == 1)
		return new APB1("APB1Name");
	else
		return new APB2("APB2Name");
}

int main(){
	AF *af = new CAF1();
	APA *apa = af->createAPA(1);
	APB *apb = af->createAPB(1);
	apa->print();
	apb->print();
	return 0;
}
